package ch5;

import java.util.Scanner;

public class GetAvg2 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double sum = 0, s;
		int i = 1;
		for (; i <= 5; i++) {
			System.out.println("请输入第" + i + "门课的成绩：");
			s = in.nextDouble();
			if (s < 0) {
				break;
			}
			sum += s;
		}
		if (i > 5) {// 没有错误
			double avg = sum / 5;
			System.out.println("5门课的平均分是：" + avg);
		} else {
			System.out.println("输入有误！");
		}
	}
}
